﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsFormsApplication2;
using WindowsFormsApplication2.Model;

namespace Anata_Client
{
    public partial class frmKonsumen : Form
    {
        ArrayList transaksiLayanan;
        ArrayList transaksiProduk;
        DataGridView dgvTransaksi;
        int id;
        int idTransaksi;

        public frmKonsumen(ref ArrayList a, ref ArrayList b, int _idTransaksi, DataGridView dgvHome)
        {
            InitializeComponent();
            dteTglLahir.Format = DateTimePickerFormat.Custom;
            dteTglLahir.CustomFormat = "yyyy-MM-dd";

            transaksiLayanan = a;
            transaksiProduk = b;
            idTransaksi = _idTransaksi;
            dgvTransaksi = dgvHome;
            id = 1;
        }

        private void btnSimpan_Click(object sender, EventArgs e)
        {
            id = (int)Konsumen.AddKonsumen(txtNama.Text, txtNomor.Text, txtNoTelp.Text, rtbAlamat.Text, (cmbGender.SelectedText == "Laki-laki" ? "TRUE" : "FALSE"), dteTglLahir.Text, txtUmur.Text);
            Form2 f = new Form2(ref transaksiLayanan, ref transaksiProduk, id, txtNama.Text, dgvTransaksi);
            f.Show();
            this.Close();
        }

        private void btnBatal_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2(ref transaksiLayanan, ref transaksiProduk, id, txtNama.Text, dgvTransaksi);
            f.Show();
            this.Close();
        }
    }
}
